﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using yiCommerce.Core;
using yiCommerce.Web.Framework;

namespace yiCommerce.Admin.Controllers
{
    public class BaseYiController : Controller
    {
        protected ActionResult AccessDeniedView()
        {
            //return new HttpUnauthorizedResult();
            return RedirectToAction("AccessDenied", "Security", new { pageUrl = this.Request.RawUrl });
        }

        protected int GetShopId()
        {

            var workContext = EngineContext.Current.Resolve<IWorkContext>();
            if (workContext != null)
            {
                //if (workContext.CurrentCustomer.IsAdmin())
                //{
                //    return 0;
                //}
                //else
                //{
                //    var shopId = workContext.CurrentCustomer.ShopId != null
                //                     ? workContext.CurrentCustomer.ShopId.Value
                //                     : 0;
                //    return shopId;
                //}
                return 0;

            }
            return 0;
        }

    }
}
